<?php
namespace app\common\model;

use think\Model;

class Player extends Model
{
    protected $connection = 'db_config_aiqi';
    public static function getplayerinfo($aid,$uid)
	{
	    $player = Player::where([['aid','=',$aid],['uid','=',$uid]])->find();
		return $player;
	}

    public static function register($data){
        $data = self::setRegisterData($data);
        $player = self::create($data);
        return $player;
    }

    public static function getOne($where){
        return Player::where($where)->find();
    }

    protected static function setRegisterData($data){

        return [
            'cid'=>$data['cid'] ?? 0,
            'account'=>$data['account'],
            'password'=>$data['password'],
            'gid'=>$data['gid'] ?? 0,
            'sid'=>$data['sid'] ?? 0,
            'client'=>$data['client'] ?? 0,
            'create_time' => time(),
            'create_ip'=>request()->ip() ?? 0,
            'login_time'=>time(),
            'login_ip'=>request()->ip() ?? 0,
            'status'=>1,
            'type'=>$data['type'] ?? 0,
            'is_age' => $data['is_age'] ?? 0,
        ];
    }
}